package com.zf.nospring.rabbitmq.consume_manual_ack_nack_reject;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.zf.nospring.rabbitmq.utils.RabbitUtils;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeoutException;

public class MsgProducer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = RabbitUtils.getDefaultConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare("test_ack", true, false, false, null);
        for (int i = 0; i < 5; i++) {
            channel.basicPublish("", "test_ack", null, ("你好a"+i).getBytes(StandardCharsets.UTF_8));
        }

        // 关闭通道和连接
        channel.close();
        connection.close();
    }
}
